
<template>
  <div class="execution">
    <basic-container>
      <avue-crud
        :permission="permissionList"
        v-model="form"
        v-bind="bindVal"
        v-on="onEvent"
        :page.sync="page"
      >
        <template slot="menuLeft">
          <el-button v-if="stm_swstinvoiceuse_dels" type="primary" size="small" @click="delBatch">删除</el-button>
        </template>
      </avue-crud>
    </basic-container>
  </div>
</template>

<script>
import {
  fetchList,
  getObj,
  addObj,
  putObj,
  delObj,
  delBatchObj
} from "@/api/subwaystm/swstinvoiceuse";
import { tableOption } from "@/const/crud/subwaystm/swstinvoiceuse";
import { mapGetters } from "vuex";
import baseCrud from '@/mixins/base-crud'

export default {
  name: "swstinvoiceuse",
  mixins: [baseCrud('subwaystm/swstinvoiceuse')],
  data() {
    return {
    };
  },
  watch:{
      'form.invoiceMoney':function(){
          this.form.invoiceName=this.form.invoiceMoney;
      },
       'form.recipientName':function(){
          this.form.recipientCode=this.form.recipientName;
      }
  },
  created() {
    this.stm_swstinvoiceuse_dels = this.permissions["stm_swstinvoiceuse_dels"];
  },
  computed: {
    ...mapGetters(["permissions"]),
    permissionList() {
      return {
        addBtn: this.vaildData(this.permissions.stm_swstinvoiceuse_add, false),
        delBtn: this.vaildData(this.permissions.stm_swstinvoiceuse_del, false),
        editBtn: this.vaildData(this.permissions.stm_swstinvoiceuse_edit, false)
      };
    }
  },
  methods: {
    delBatch() {
      if (
        this.$refs.crud.tableSelect.length < 1 ||
        this.$refs.crud.tableSelect.length > 10
      ) {
        this.$message.error("选中表数量不合法，数量最少1个或最多为10个");
        return false;
      }
      let ids = [];
      for (const table of this.$refs.crud.tableSelect) {
        ids.push(table.id);
      }
      this.$confirm("确定删除吗？").then(() => {
        delBatchObj(ids).then(data => {
          this.$message.success("删除成功");
          this.getList(this.page);
        })
      })
    },

  }
};
</script>
